package cz.fit.vutbr.pis2012.augeaswh.control.ekonom.subscriber;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

import cz.fit.vutbr.pis2012.augeaswh.managers.SubscriberManager;
import cz.fit.vutbr.pis2012.augeaswh.persistence.Subscriber;

@ManagedBean
@ViewScoped
public class SubscriberConfirmDeleteDialogBean {
	@EJB
	private SubscriberManager sm;	
	private Subscriber subscriber;
	
	public String getTitle() {
		return "Deleting subscriber";
	}
	
	public String getQuestion() {
		if(this.subscriber==null)
			return "";
		return "Are you sure you want to delete the subscriber "+subscriber.getName()+"?"; 
	}
	
	public Subscriber getSubscriber() {
		return subscriber;
	}

	public void setSubscriber(Subscriber supplier) {
		this.subscriber = supplier;
	}
	
	public void submit() {
		if(this.subscriber!=null) {
			sm.delete(this.subscriber);
			this.subscriber=null;
		}
	}
}
